<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取当前解析的cURL的相关传输信息</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.curl-multi-getcontent.html">curl_multi_getcontent</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.curl-multi-init.html">curl_multi_init</a></div>
 <div class="up"><a href="ref.curl.html">cURL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.curl-multi-info-read" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">curl_multi_info_read</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">curl_multi_info_read</span> &mdash; <span class="dc-title">获取当前解析的cURL的相关传输信息</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.curl-multi-info-read-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>curl_multi_info_read</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$mh</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$msgs_in_queue</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
  ] )</div>

  <p class="para rdfs-comment">
   查询批处理句柄是否单独的传输线程中有消息或信息返回。消息可能包含诸如从单独的传输线程返回的错误码或者只是传输线程有没有完成之类的报告。
  </p>
  <p class="para">   
   重复调用这个函数，它每次都会返回一个新的结果，直到这时没有更多信息返回时，<strong><code>FALSE</code></strong> 被当作一个信号返回。通过<em><code class="parameter">msgs_in_queue</code></em>返回的整数指出将会包含当这次函数被调用后，还剩余的消息数。
  </p>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">
    返回的资源指向的数据调用<span class="function"><a href="function.curl-multi-remove-handle.html" class="function">curl_multi_remove_handle()</a></span>后将不会存在。
   </p>
  </div>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.curl-multi-info-read-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    <dt>
<em><code class="parameter">mh</code></em>
</dt>
<dd>
<p class="para">由 <span class="function"><a href="function.curl-multi-init.html" class="function">curl_multi_init()</a></span> 返回的 cURL 多个句柄。</p></dd>

    
     <dt>
<em><code class="parameter">msgs_in_queue</code></em></dt>

     <dd>

      <p class="para">
       仍在队列中的消息数量。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.curl-multi-info-read-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回相关信息的数组，失败时返回<strong><code>FALSE</code></strong>。
  </p>
  <p class="para">
   <table class="doctable table">
    <caption><strong>返回数组的内容</strong></caption>
    
     <thead>
      <tr>
       <th>Key:</th>
       <th>Value:</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td><em>msg</em></td>
       <td><strong><code>CURLMSG_DONE</code></strong>常量。其他返回值当前不可用。</td>
      </tr>

      <tr>
       <td><em>result</em></td>
       <td><strong><code>CURLE_*</code></strong>常量之一。如果一切操作没有问题，将会返回<strong><code>CURLE_OK</code></strong>常量。</td>
      </tr>

      <tr>
       <td><em>handle</em></td>
       <td>cURL资源类型表明它有关的句柄。</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.curl-multi-info-read-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4129">
    <p><strong>Example #1 一个<span class="function"><strong>curl_multi_info_read()</strong></span>范例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$urls&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"http://www.cnn.com/"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"http://www.bbc.co.uk/"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"http://www.yahoo.com/"<br /></span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$mh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_multi_init</span><span style="color: #007700">();<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$urls&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$url</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$conn</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">curl_init</span><span style="color: #007700">(</span><span style="color: #0000BB">$url</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">curl_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">],&nbsp;</span><span style="color: #0000BB">CURLOPT_RETURNTRANSFER</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">curl_multi_add_handle</span><span style="color: #007700">(</span><span style="color: #0000BB">$mh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$conn</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]);<br />}<br /><br />do&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$status&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_multi_exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$mh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$active</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$info&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_multi_info_read</span><span style="color: #007700">(</span><span style="color: #0000BB">$mh</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">false&nbsp;</span><span style="color: #007700">!==&nbsp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$info</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}&nbsp;while&nbsp;(</span><span style="color: #0000BB">$status&nbsp;</span><span style="color: #007700">===&nbsp;</span><span style="color: #0000BB">CURLM_CALL_MULTI_PERFORM&nbsp;</span><span style="color: #007700">||&nbsp;</span><span style="color: #0000BB">$active</span><span style="color: #007700">);<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$urls&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$url</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">curl_multi_getcontent</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">curl_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]);<br />}<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">curl_multi_info_read</span><span style="color: #007700">(</span><span style="color: #0000BB">$mh</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(3) {
  [&quot;msg&quot;]=&gt;
  int(1)
  [&quot;result&quot;]=&gt;
  int(0)
  [&quot;handle&quot;]=&gt;
  resource(5) of type (curl)
}
array(3) {
  [&quot;msg&quot;]=&gt;
  int(1)
  [&quot;result&quot;]=&gt;
  int(0)
  [&quot;handle&quot;]=&gt;
  resource(7) of type (curl)
}
array(3) {
  [&quot;msg&quot;]=&gt;
  int(1)
  [&quot;result&quot;]=&gt;
  int(0)
  [&quot;handle&quot;]=&gt;
  resource(6) of type (curl)
}
bool(false)
</pre></div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-function.curl-multi-info-read-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.2.0</td>
       <td>
        <em><code class="parameter">msgs_in_queue</code></em>被加入。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.curl-multi-info-read-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.curl-multi-init.html" class="function" rel="rdfs-seeAlso">curl_multi_init()</a> - 返回一个新cURL批处理句柄</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.curl-multi-getcontent.html">curl_multi_getcontent</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.curl-multi-init.html">curl_multi_init</a></div>
 <div class="up"><a href="ref.curl.html">cURL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
